/******************************************************************************
 * @ CompanyName : Copyright (C), 2031,  xx Information Technology Co., Ltd.
 * @ FileName    : event_schedule_config.c
 * @ Descripttion: event and schedule config function
 * @ version     : 1.0
 * @ Author      : SunXin
 * @ Date        : 2023-06-05 11:39:26
 * @ LastEditTime: 2023-06-28 18:20:56
 * @ Chargelog   : 1.xxx
 ******************************************************************************/


/******************************************************************************/
//                          header file reference
/******************************************************************************/
// system lay includes
#include "event_schedule_config.h"

// hal lay include

// device lay include

// app lay includes
#include "app_system.h"


/******************************************************************************/
//                          macro definition
/******************************************************************************/
// Debugging print macro definition
#if((PRINT_MODE_DEF_RTT == PRINT_CONFIG_MODE)&&(LOG_ON == EVENT_SCHEDULE_LOG_EN))
    #define LOCAL_DEBUG(...)         SEGGER_RTT_printf(0,__VA_ARGS__)
#elif((PRINT_MODE_DEF_UART == PRINT_CONFIG_MODE)&&(LOG_ON == EVENT_SCHEDULE_LOG_EN))
    #define LOCAL_DEBUG(...)         debug_info(__VA_ARGS__)
#else
    #include <stdio.h>
    #define LOCAL_DEBUG(...)        printf(__VA_ARGS__)
#endif

// Dynamic request macro definition
#ifdef _USE_RTOS_DEF_
    #define data_malloc         kos_malloc
    #define data_free           kos_free
#else
    #define data_malloc         malloc
    #define data_free           free
#endif


/******************************************************************************/
//                          variable definition
/******************************************************************************/


/******************************************************************************/
//                          static function declaration
/******************************************************************************/


/******************************************************************************/
//                          function definition
/******************************************************************************/








/***********************************************************************************/
//                  macro definition           
/***********************************************************************************/


/***********************************************************************************/
//                  variable definition           
/***********************************************************************************/


/***********************************************************************************/
//                  Function declaration           
/***********************************************************************************/
//===============================================================================
//The following are the public interface functions
//===============================================================================
uint16_t GetGlobalCurrentYear(void);
uint8_t GetGlobalCurrentMonth(void);
uint8_t GetGlobalCurrentWeek(void);
uint8_t GetGlobalCurrentDay(void);
uint8_t GetGlobalYestodayDay(void);
uint8_t GetGlobalCurrentHour(void);
uint8_t GetGlobalCurrentMin(void);
uint8_t GetGlobalCurrentSec(void);
uint32_t GetGlobalCurrentUTC(void);
uint32_t GetGlobalCurrentSystick(void);
//===============================================================================
//The following are the public interface functions
//===============================================================================
const STRUCT_SYSTEM_INTERNAL_API es_sys_api = 
{
    .get_year = GetGlobalCurrentYear,
    .get_month = GetGlobalCurrentMonth,
    .get_week = GetGlobalCurrentWeek,
    .get_day = GetGlobalCurrentDay,
    .get_yestoday_day = GetGlobalYestodayDay,
    .get_hour = GetGlobalCurrentHour,
    .get_min = GetGlobalCurrentMin,
    .get_sec = GetGlobalCurrentSec,
    .get_utc = GetGlobalCurrentUTC,
    .get_tick = GetGlobalCurrentSystick,
};

/**
 ***************************************************************************
 * @name GetGlobalCurrentYear
 * @brief Gets the current year
 * @parm[in] None
 *
 * @return uint16_t year
 ***************************************************************************
 */
uint16_t GetGlobalCurrentYear(void)
{
    //Fill the application layer interface ...
    /*sys_time_t sys_time;  
    get_from_data_hub(DEV_TIME_H, sizeof(sys_time), &sys_time);
    time_type_t local_time;
    local_time = utc_to_local_time(sys_time.utc, sys_time.time_zone);
    return local_time.tm_year;
    */
    return 2021;
}

/**
 ***************************************************************************
 * @name GetGlobalCurrentMonth
 * @brief Gets the current month
 * @parm[in] None
 *
 * @return uint16_t month
 ***************************************************************************
 */
uint8_t GetGlobalCurrentMonth(void)
{
    //Fill the application layer interface ...
    /*sys_time_t sys_time;  
    get_from_data_hub(DEV_TIME_H, sizeof(sys_time), &sys_time);
    time_type_t local_time;
    local_time = utc_to_local_time(sys_time.utc, sys_time.time_zone);
    return local_time.tm_mon;*/
    return 12;
}

/**
 ***************************************************************************
 * @name GetGlobalCurrentWeek
 * @brief Gets the current week
 * @parm[in] None
 *
 * @return uint8_t week
 ***************************************************************************
 */
uint8_t GetGlobalCurrentWeek(void)
{
    //Fill the application layer interface ...
    /*sys_time_t sys_time;  
    get_from_data_hub(DEV_TIME_H, sizeof(sys_time), &sys_time);
    time_type_t local_time;
    local_time = utc_to_local_time(sys_time.utc, sys_time.time_zone);
    return local_time.tm_wday;*/
    return 1;
}

/**
 ***************************************************************************
 * @name GetGlobalCurrentDay
 * @brief Gets the current day
 * @parm[in] None
 *
 * @return uint8_t day
 ***************************************************************************
 */
uint8_t GetGlobalCurrentDay(void)
{
    //Fill the application layer interface ...
    /*sys_time_t sys_time;  
    get_from_data_hub(DEV_TIME_H, sizeof(sys_time), &sys_time);
    time_type_t local_time;
    local_time = utc_to_local_time(sys_time.utc, sys_time.time_zone);
    return local_time.tm_mday;*/
    return 27;
}

/**
 ***************************************************************************
 * @name GetGlobalYestodayDay
 * @brief Get yesterday's day
 * @parm[in] none
 *
 * @return uint8_t day
 ***************************************************************************
 */
uint8_t GetGlobalYestodayDay(void)
{
    //Fill the application layer interface ...
    /*
    if(NULL != dest_time)
    {
        sys_time_t sys_time;  
        get_from_data_hub(DEV_TIME_H, sizeof(sys_time), &sys_time);
        sys_time.utc += 86400;
        time_type_t local_time;
        local_time = utc_to_local_time(sys_time.utc, sys_time.time_zone);
        memcpy(dest_time,&local_time,sizeof(time_type_t));
    }*/
    return 0;
}

/**
 ***************************************************************************
 * @name GetGlobalCurrentHour
 * @brief Gets the current time
 * @parm[in] none
 *
 * @return uint8_t hour
 ***************************************************************************
 */
uint8_t GetGlobalCurrentHour(void)
{
    //Fill the application layer interface ...
    /*
    sys_time_t sys_time;  
    get_from_data_hub(DEV_TIME_H, sizeof(sys_time), &sys_time);
    time_type_t local_time;
    local_time = utc_to_local_time(sys_time.utc, sys_time.time_zone);
    return local_time.tm_hour;
    */
    return 0;
}

/**
 ***************************************************************************
 * @name GetGlobalCurrentMin
 * @brief Gets the current minute
 * @parm[in] none
 *
 * @return uint8_t minute
 ***************************************************************************
 */
uint8_t GetGlobalCurrentMin(void)
{
    //Fill the application layer interface ...
    /*
    sys_time_t sys_time;  
    get_from_data_hub(DEV_TIME_H, sizeof(sys_time), &sys_time);
    time_type_t local_time;
    local_time = utc_to_local_time(sys_time.utc, sys_time.time_zone);
    return local_time.tm_min;
    */
    return 0;
}

/**
 ***************************************************************************
 * @name GetGlobalCurrentSec
 * @brief Gets the current second
 * @parm[in] none
 *
 * @return uint8_t second
 ***************************************************************************
 */
uint8_t GetGlobalCurrentSec(void)
{
    //Fill the application layer interface ...
    /*sys_time_t sys_time;  
    get_from_data_hub(DEV_TIME_H, sizeof(sys_time), &sys_time);
    time_type_t local_time;
    local_time = utc_to_local_time(sys_time.utc, sys_time.time_zone);
    return local_time.tm_sec;*/
    return 0;
}

/**
 ***************************************************************************
 * @name GetGlobalCurrentUTC
 * @brief Get the current utc
 * @parm[in] none
 *
 * @return uint32_t utc
 ***************************************************************************
 */
uint32_t GetGlobalCurrentUTC(void)
{
    //Fill the application layer interface ...
    /*sys_time_t sys_time;  
    get_from_data_hub(DEV_TIME_H, sizeof(sys_time), &sys_time);
    return sys_time.utc;*/
    return 0;
}


/*****************************************************************************/

